package com.example.su_shi_tan_bas_lib.utils;

import android.graphics.drawable.Drawable;

import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;


import com.example.su_shi_tan_bas_lib.R;
import com.example.su_shi_tan_bas_lib.base.BaseFragmentEx;
import com.example.su_shi_tan_bas_lib.global.AppGlobals;

import me.yokeyword.fragmentation.ISupportFragment;

public class ShUtils {

    /**
     * 图片染色
     */
    public static Drawable tintDrawable(int imageId, @ColorInt int colors) {
        Drawable drawable = ContextCompat.getDrawable(AppGlobals.getApplication(), imageId);
        final Drawable wrappedDrawable = tintDrawable(drawable, colors);
        DrawableCompat.setTint(wrappedDrawable, colors);
        return wrappedDrawable;
    }

    public static Drawable tintDrawable(Drawable drawable, @ColorInt int colors) {
        final Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(wrappedDrawable, colors);
        return wrappedDrawable;
    }

//    /**
//     * 碎片启动不隐藏前一个碎片
//     */
    public static void startFragmentDoNotHideSelf(BaseFragmentEx from, BaseFragmentEx to) {
        from.extraTransaction()
                .setCustomAnimations(
                        R.anim.v_fragment_enter,
                        0,
                        0,
                        R.anim.v_fragment_exit)
                .startDontHideSelf(to,ISupportFragment.SINGLETOP);
    }

}
